const { JaxService } = require('jax')

class Service extends JaxService {
  // 获取用户信息
  async getUserInfo(userId) {
    const { ctx } = this
    const { helper } = ctx

    const doc = await ctx.model.User.findOne({
      _id: userId,
    })

    if (!doc) throw '无效用户'

    const userInfo = helper.exclude(doc.toJSON(), ['password', 'isDelete', 'isOpen', 'updatedAt'])

    return userInfo
  }
}

module.exports = Service
